// 1.在执行完new,生成实例后
var hook = {
    args: [
      "name",
      "age",
    ],
    taps: [
    ],
    call: function (...args) {
      this.call = this._createCall('sync');//调用它的时候 ，它会动态创建call函数，重写this.call属性
      return this.call(...args);//执行新创建的call方法，
    },
    callAsync: function (...args) {
      this.callAsync = this._createCall('async');//调用它的时候 ，它会动态创建callAsync函数，重写this.callAsync属性
      return this.callAsync(...args);//执行新创建的call方法，
    },
    promise: function (...args) {
      this.promise = this._createCall('promise');//调用它的时候 ，它会动态创建callAsync函数，重写this.callAsync属性
      return this.promise(...args);//执行新创建的call方法，
    },
    interceptors: [
    ],
  }
// 2.执行hook.tap过程中生成的tapInfo
const tapInfo = {
    name: "1",
    type: "sync",
    fn: (name, age) => {
      console.log(1, name, age);
    },
 }
// 3.执行hook.tap结束后，此时实例为
hook = {
    args: [
      "name",
      "age",
    ],
    taps: [
      {
        name: "1",
        type: "sync",
        fn: (name, age) => {
          console.log(1, name, age);
        },
      },
      {
        name: "2",
        type: "sync",
        fn: (name, age) => {
          console.log(2, name, age);
        },
      },
      {
        name: "3",
        type: "sync",
        fn: (name, age) => {
          console.log(3, name, age);
        },
      },
    ],
    call: function (...args) {
      this.call = this._createCall('sync');//调用它的时候 ，它会动态创建call函数，重写this.call属性
      return this.call(...args);//执行新创建的call方法，
    },
    callAsync: function (...args) {
      this.callAsync = this._createCall('async');//调用它的时候 ，它会动态创建callAsync函数，重写this.callAsync属性
      return this.callAsync(...args);//执行新创建的call方法，
    },
    promise: function (...args) {
      this.promise = this._createCall('promise');//调用它的时候 ，它会动态创建callAsync函数，重写this.callAsync属性
      return this.promise(...args);//执行新创建的call方法，
    },
    interceptors: [
    ],
  }
// 4.执行hook.call生成的hook实例为
hook = {
    args: [
      "name",
      "age",
    ],
    taps: [
      {
        name: "1",
        type: "sync",
        fn: (name, age) => {
          console.log(1, name, age);
        },
      },
      {
        name: "2",
        type: "sync",
        fn: (name, age) => {
          console.log(2, name, age);
        },
      },
      {
        name: "3",
        type: "sync",
        fn: (name, age) => {
          console.log(3, name, age);
        },
      },
    ],
    call: function (...args) {
      this.call = this._createCall('sync');//调用它的时候 ，它会动态创建call函数，重写this.call属性
      return this.call(...args);//执行新创建的call方法，
    },
    callAsync: function (...args) {
      this.callAsync = this._createCall('async');//调用它的时候 ，它会动态创建callAsync函数，重写this.callAsync属性
      return this.callAsync(...args);//执行新创建的call方法，
    },
    promise: function (...args) {
      this.promise = this._createCall('promise');//调用它的时候 ，它会动态创建callAsync函数，重写this.callAsync属性
      return this.promise(...args);//执行新创建的call方法，
    },
    interceptors: [
    ],
    _x: [
      (name, age) => {
        console.log(1, name, age);
      },
      (name, age) => {
        console.log(2, name, age);
      },
      (name, age) => {
        console.log(3, name, age);
      },
    ],
  }
// 5.执行factory.create传入的参数options为
options = {
    taps: [
      {
        name: "1",
        type: "sync",
        fn: (name, age) => {
          console.log(1, name, age);
        },
      },
      {
        name: "2",
        type: "sync",
        fn: (name, age) => {
          console.log(2, name, age);
        },
      },
      {
        name: "3",
        type: "sync",
        fn: (name, age) => {
          console.log(3, name, age);
        },
      },
    ],
    args: [
      "name",
      "age",
    ],
    interceptors: [
    ],
    type: "sync",
  }
// 6.生成函数，并且传入参数(...args)执行
(function anonymous(name, age) {
    var _x = this._x;//this是钩子的实例 _x是事件函数的数组
    
    var _fn0 = _x[0];
    _fn0(name, age);
  
    var _fn1 = _x[1];
    _fn1(name, age);
  
    var _fn2 = _x[2];
    _fn2(name, age);
  })(...args)